using UnityEngine;

public abstract class DrawableGameObject : MonoBehaviour {

    protected GameAnimation gameAnimation;

    private Texture2D[] firstAnimation, secondAnimation, thirdAnimation, fourthAnimation, fifthAnimation;

    protected void SetAnimations(Texture2D[] firstAnimation, Texture2D[] secondAnimation, Texture2D[] thirdAnimation, Texture2D[] fourthAnimation, Texture2D[] fifthAnimation)
    {
        this.firstAnimation = firstAnimation;
        this.secondAnimation = secondAnimation;
        this.thirdAnimation = thirdAnimation;
        this.fourthAnimation = fourthAnimation;
		this.fifthAnimation = fifthAnimation;
    }

	public virtual void Start () 
    {
        gameAnimation = GetComponent<GameAnimation>();
	}

    protected void RunAnimation(string animation, string animationMode)
    {
        if (gameAnimation.currentAnimation != animation)
        {
            gameAnimation.currentAnimation = animation;

            switch (animation)
            {
                case "First":
                    gameAnimation.AddAnimation(firstAnimation, animationMode);
                    gameAnimation.Play();
                    break;
                case "Second":
                    gameAnimation.AddAnimation(secondAnimation, animationMode);
                    gameAnimation.Play();

                    break;
                case "Third":
                    gameAnimation.AddAnimation(thirdAnimation, animationMode);
                    gameAnimation.Play();
                    break;
                case "Fourth":
                    gameAnimation.AddAnimation(fourthAnimation, animationMode);
                    gameAnimation.Play();
                    break;
				case "Fifth":
                    gameAnimation.AddAnimation(fifthAnimation, animationMode);
					gameAnimation.Play();
					break;
                default:
                    break;
            }
        }
    }

    protected void StopAnimation()
    {
        if (gameAnimation.isPlaying())
        {
            gameAnimation.Stop();
        }
    }
    
}
